﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using WpfRcp.Core.Services;
using WpfRcp.Core.Views.Presenters;

namespace RCPApplication.UI.Views.Presenters
{
    public class AboutViewPresentationModel : PresenterBase<IAboutView>
    {
        private readonly IRcpSettings m_RcpSettings;
        private string m_VersionString;

        public AboutViewPresentationModel(IRcpSettings rcpSettings)
        {
            m_RcpSettings = rcpSettings;
        }

        protected override void Initialize()
        {
            DataBind();
        }

        public IRcpSettings RcpSettings
        {
            get { return m_RcpSettings; }
        }

        public string VersionString
        {
            get { return m_VersionString; }
            private set
            {
                m_VersionString = value;
                OnPropertyChanged("VersionString");
            }
        }

        private void DataBind()
        {
#if (DEBUG)
            VersionString =
                string.Format(
                    (IntPtr.Size == 4
                         ? Properties.Resources.VersionString32
                         : Properties.Resources.VersionString64) + " (Debug)",
                    Assembly.GetEntryAssembly().GetName().Version);
#else
            if (IntPtr.Size == 4)
                VersionString = string.Format(Properties.Resources.VersionString32,
                    Assembly.GetEntryAssembly().GetName().Version);
            else
                VersionString = string.Format(Properties.Resources.VersionString64,
                    Assembly.GetEntryAssembly().GetName().Version);
#endif
        }
    }
}
